import { DateTime } from 'luxon'
import { belongsTo, column } from '@adonisjs/lucid/orm'
import type { BelongsTo } from '@adonisjs/lucid/types/relations'
import Dict from '#models/dict'
import Member from '#models/member'
import CommonBaseModel from '#common/base_model'

export default class SalesOrder extends CommonBaseModel {
  /** 来源ID */
  @column()
  declare fkSourceId: number | null

  /** 会员ID */
  @column()
  declare fkMemberId: number | null

  /** 单据单号 */
  @column()
  declare billNo: string

  /** 单据日期 */
  @column.dateTime()
  declare billDate: DateTime

  /** 单据类型 */
  @column()
  declare billType: string

  /** 客户名称 */
  @column()
  declare customerName: string

  /** 客户性别 */
  @column()
  declare customerSex: number

  /** 客户手机号 */
  @column()
  declare customerPhone: string

  /** 实际金额 */
  @column()
  declare actualPrice: number

  /** 实际支付金额 */
  @column()
  declare actualPayPrice: number

  /** 总金额 */
  @column()
  declare totalAmount: number

  /** 单据状态 */
  @column()
  declare status: number

  /** 备注 */
  @column()
  declare memo: string

  /** 单据来源 */
  @belongsTo(() => Dict)
  declare source: BelongsTo<typeof Dict>

  /** 会员资料 */
  @belongsTo(() => Member)
  declare member: BelongsTo<typeof Member>
}
